package graphing;

public enum Waveform {

	SAW_RIGHT {  //saw wave w/ dropoff on the right side
			public float calculateValue(float t, float wavelength){
				return -1+2*(t%wavelength)/wavelength;
			}
		},
	SAW_LEFT {  //saw wave w/ dropoff on the left side
			public float calculateValue(float t, float wavelength){
				return 1-2*(t%wavelength)/wavelength;
			}
		},
	TRIANGLE {  //triangle w/ peaks at the sides
			public float calculateValue(float t, float wavelength){
				return 2*Math.abs(-1+2*(t%wavelength)/wavelength)-1;
			}
		},
	SQUARE {  //square wave
			public float calculateValue(float t, float wavelength){
				if(t%wavelength < wavelength/2) return 1;
				return -1;
			}
		},
	SINE {  //classic sine wave
			public float calculateValue(float t, float wavelength){
				return (float)Math.sin(2*Math.PI*(t%wavelength)/wavelength);
			}
		};
	
	public float calculateValue(float t, float wavelength){return 0;}
}
